package com.wuyou.mid;


import javax.print.attribute.HashAttributeSet;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @Description 1657. 确定两个字符串是否接近
 * @Author yh.zhang
 * @Date 2023/11/30 9:20
 */
public class CloseStrings {


    public static void main(String[] args) {
//        String word1 = "cabbba";
//        String word2 = "abbccc";
//        String word1 = "cabbba";
//        String word2 = "aabbss";
        String word1 = "abbzzca";
        String word2 = "babzzcz";

        System.out.println(solution_1(word1, word2));
    }

    public static boolean solution_1(String word1, String word2) {
        int[] cnt1 = new int[26], cnt2 = new int[26];
        for (char c : word1.toCharArray()) {
            cnt1[c - 'a']++;
        }
        for (char c : word2.toCharArray()) {
            cnt2[c - 'a']++;
        }
        for (int i = 0; i < 26; i++) {
            if ((cnt1[i] == 0) != (cnt2[i] == 0))
                return false;
        }
        Arrays.sort(cnt1);
        Arrays.sort(cnt2);
        return Arrays.equals(cnt1, cnt2);
    }
}
